import {
  q as n,
  p as M,
  ap as R,
  X as v,
  f as V,
  H as A,
  av as y,
  aw as N,
  az as O,
  as as s,
  at as m
} from "./index-b50e6ef9.js";
import { h as T, a as b } from "./health-43e84a7c.js";
function j(x) {
  const u = n([]),
    a = n(!0);
  n({}), M();
  const d = n(1),
    p = n(10),
    h = n(""),
    w = R("reload"),
    f = v({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    B = v({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    C = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "用户ID", prop: "user_id", minWidth: 50 },
      { label: "手机号", prop: "user_phone", minWidth: 150 },
      { label: "姓名", prop: "user_name", minWidth: 150 },
      { label: "创建时间", prop: "create_time", minWidth: 150 },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    S = V(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    O(e);
  }
  async function J(e) {
    const o = { id: e.id },
      i = JSON.stringify(o),
      r = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(i)) },
      t = await T(r);
    t.code == 200
      ? (m("删除成功", { type: "success" }), w())
      : m(t.msg, { type: "error" });
  }
  function W() {}
  function z(e) {
    (p.value = e), l(void 0, e);
  }
  function U(e) {
    (d.value = e), l(e, void 0);
  }
  function _(e) {}
  function k(e) {
    (B.text = `正在加载第${e}页...`),
      (a.value = !0),
      y(600).then(() => {
        a.value = !1;
      });
  }
  async function D(e) {
    (a.value = !0), (h.value = e);
    const o = { page: d.value, pagesize: p.value, user_phone: h.value },
      i = JSON.stringify(o),
      r = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(i)) },
      { data: t } = await b(r);
    (u.value = t.data),
      (f.total = t.total),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function l(e = d.value, o = p.value) {
    const i = { page: e, pagesize: o, user_phone: h.value },
      g = JSON.stringify(i),
      t = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(g)) },
      c = await b(t);
    c.code === 200
      ? ((u.value = c.data.data),
        (f.total = c.data.total),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : m(c.msg, { type: "error" });
  }
  const L = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    A(() => {
      y().then(() => {
        const { setWatermark: e } = N(x.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        l();
    }),
    {
      loading: a,
      columns: C,
      dataList: u,
      pagination: f,
      buttonClass: S,
      handleList: l,
      onSearch: D,
      resetForm: L,
      handleaddUser: W,
      handleUpdate: I,
      handleDelete: J,
      handleSizeChange: z,
      handleCurrentChange: U,
      handleSelectionChange: _,
      onCurrentChange: k
    }
  );
}
export { j as useRole };
